import Pool from '../js/base/pool.js'

// 单例模式
let instance

/**
 * 全局状态管理器
 */
export default class DataBus {
  constructor() {
    if (instance)
      return instance

    instance = this

    this.pool = new Pool()

    this.reset()
  }

  reset() {
    this.frame = 0
    this.score = 0
    this.block = []
    this.animations = []
    this.gameOver = false
    this.mode ='nomal'
  }

  /**
   * 回收敌人，进入对象池
   * 此后不进入帧循环
   */
  removeBlock(block) {
    let temp = this.blocks.shift()

    temp.visible = false

    this.pool.recover('block', block)
  }

  
}